{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "import torchvision.transforms as transforms #处理数据模块\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "mnist = torchvision.datasets.FashionMNIST(root= \"D:\\BaiduNetdiskDownload\\dataset\" #指定数据集位置,会找该目录下名为FashionMNIST的文件\n",
    "                                         ,download = False #download=True会自动下载\n",
    "                                         ,train = True #train是否为测试用数据\n",
    "                                         ,transform = transforms.ToTensor())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([60000, 28, 28])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist.data.shape   #特征张量 [60000,1,28,28] [sample_size, height, width, color] color可在前或后"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist.targets.unique() #目标，10分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['T-shirt/top',\n",
       " 'Trouser',\n",
       " 'Pullover',\n",
       " 'Dress',\n",
       " 'Coat',\n",
       " 'Sandal',\n",
       " 'Shirt',\n",
       " 'Sneaker',\n",
       " 'Bag',\n",
       " 'Ankle boot']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist.classes  #文字分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from torch import nn\n",
    "from torch import optim\n",
    "from torch.utils.data import DataLoader, TensorDataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr = 0.15\n",
    "gamma = 0.1\n",
    "epochs = 10\n",
    "bs = 128"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "batchdata = DataLoader(mnist\n",
    "                      ,batch_size = bs\n",
    "                      ,shuffle = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([128, 1, 28, 28])\n",
      "torch.Size([128])\n"
     ]
    }
   ],
   "source": [
    "for x,y in batchdata:\n",
    "    print(x.shape)\n",
    "    print(y.shape)\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x2911d3219d0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAASD0lEQVR4nO3db2yd5XkG8Os6f2zHTkjimDgJScOfBRZKN2AeMNIhKrQO2AdAU6vC1GUVW/oBJrp10hCTVqR+GJpaEB8qpBRYU1RAaAURVYiBsqq0W0UxKCShgQZQRpM4cUJI4uDEPj7n3ge/2Qz4vZ/Dec+f136unxTZPrdfnycnufyec+73eR6aGURk/it0egAi0h4Ku0gkFHaRSCjsIpFQ2EUiUWrnnXWx23rQ1867nBNqS/zHpNrtH18+9GETR5MflRX+41I65XeSeHy8mcOZE07j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fO33bgBeIPkqyU2dHswsBs1sBJj+zwNgeYfH83HBbbzb6WPbjOfmsWtk+/OsOhH22baSylP/b4OZXQ7gBgB3JE9XpT51bePdLrNsM54LjW5/nlUnwr4PwMydDFcDONCBcczKzA4kH0cBPIP8bUV96MwOusnH0Q6P5//kaRvv2bYZRw4eu05uf96JsL8CYB3J80h2AfgKgK0dGMcnkOxL3jgByT4AX0T+tqLeCmBj8vlGAM92cCwfkZdtvNO2GUeHH7uOb39uZm3/A+BGTL8j/w6Af+rEGFLGdT6A15M/b3R6bACewPTTugqmnxHdDmAZgG0A9iQf+3M0tscA7ASwA9PBWtmhsX0e0y8NdwDYnvy5sdOPnTOutjxuulxWJBK6gk4kEgq7SCQUdpFIKOwikVDYRSKhsItEQmEXicT/AvqGgDe2BO/UAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#输入是4维度, 128,1,28,28,需要转成二维 128, 28*28\n",
    "input_ = mnist.data[0].numel() #张量中有多少元素\n",
    "input_\n",
    "plt.imshow(mnist[20][0].view(28, 28).numpy())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#输出,10分类\n",
    "output_ = len(mnist.targets.unique())\n",
    "output_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#定义好神经网络架构\n",
    "class Model(nn.Module):\n",
    "    def __init__(self, in_features = 10, out_features = 2):\n",
    "        super().__init__()\n",
    "        self.normalize = nn.BatchNorm2d(num_features=1)\n",
    "        self.linear1 = nn.Linear(in_features, 128, bias = False)\n",
    "        self.output = nn.Linear(128, out_features, bias = False)\n",
    "        \n",
    "    def forward(self, x):\n",
    "        x = self.normalize(x)\n",
    "        x = x.view(-1, 28*28) #转换维度,第二维是28*28,第一维度自动计算\n",
    "        sigma1 = torch.relu(self.linear1(x))\n",
    "        sigma2 = torch.log_softmax(self.output(sigma1), dim=1)\n",
    "        return sigma2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "#定义损失函数，优化算法\n",
    "#定义一个训练函数\n",
    "def fit(net, batchdata, lr=0.01, epochs = 5, gamma = 0):\n",
    "    criterion = nn.NLLLoss()\n",
    "    opt = optim.SGD(net.parameters(), lr = lr, momentum = gamma)\n",
    "    samples = 0\n",
    "    correct = 0\n",
    "    for epoch in range(epochs): #全数据训练几次\n",
    "        for batch_idx, (x,y) in enumerate(batchdata):\n",
    "            y = y.view(x.shape[0]) #降维,把y降成一维\n",
    "            sigma = net.forward(x) #正向传播\n",
    "            loss = criterion(sigma, y)\n",
    "            loss.backward()   #反向传播\n",
    "            opt.step() #更新梯度\n",
    "            opt.zero_grad() #梯度清零\n",
    "            #准确率，全部判断正确的样本数量/已经看过的总样本量\n",
    "            yhat = torch.max(sigma, 1)[1]\n",
    "            correct = correct + torch.sum(yhat == y)\n",
    "            samples = samples + x.shape[0] #记录训练多少样本\n",
    "            if((batch_idx + 1) % 125 == 0 or batch_idx == len(batchdata) - 1):\n",
    "                print(\"Epoch{}:[{}/{} {:.0f}%] Loss:{:.6f}, Accuracy:{:.3f}\".format(epoch + 1\n",
    "                                                  , samples\n",
    "                                                  , epochs * len(batchdata.dataset)\n",
    "                                                  , float(samples*100 / (epochs * len(batchdata.dataset)))\n",
    "                                                  , loss.data.item()\n",
    "                                                  , float(100 * correct / samples)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch1:[16000/600000 3%] Loss:0.637895, Accuracy:74.338\n",
      "Epoch1:[32000/600000 5%] Loss:0.447158, Accuracy:77.828\n",
      "Epoch1:[48000/600000 8%] Loss:0.521229, Accuracy:79.988\n",
      "Epoch1:[60000/600000 10%] Loss:0.405671, Accuracy:81.023\n",
      "Epoch2:[76000/600000 13%] Loss:0.416994, Accuracy:82.072\n",
      "Epoch2:[92000/600000 15%] Loss:0.429837, Accuracy:82.800\n",
      "Epoch2:[108000/600000 18%] Loss:0.432052, Accuracy:83.360\n",
      "Epoch2:[120000/600000 20%] Loss:0.298268, Accuracy:83.723\n",
      "Epoch3:[136000/600000 23%] Loss:0.363600, Accuracy:84.204\n",
      "Epoch3:[152000/600000 25%] Loss:0.294783, Accuracy:84.568\n",
      "Epoch3:[168000/600000 28%] Loss:0.265620, Accuracy:84.890\n",
      "Epoch3:[180000/600000 30%] Loss:0.392879, Accuracy:85.092\n",
      "Epoch4:[196000/600000 33%] Loss:0.364119, Accuracy:85.364\n",
      "Epoch4:[212000/600000 35%] Loss:0.403001, Accuracy:85.637\n",
      "Epoch4:[228000/600000 38%] Loss:0.234768, Accuracy:85.847\n",
      "Epoch4:[240000/600000 40%] Loss:0.163554, Accuracy:85.994\n",
      "Epoch5:[256000/600000 43%] Loss:0.324602, Accuracy:86.209\n",
      "Epoch5:[272000/600000 45%] Loss:0.353036, Accuracy:86.374\n",
      "Epoch5:[288000/600000 48%] Loss:0.245920, Accuracy:86.544\n",
      "Epoch5:[300000/600000 50%] Loss:0.247820, Accuracy:86.656\n",
      "Epoch6:[316000/600000 53%] Loss:0.368780, Accuracy:86.827\n",
      "Epoch6:[332000/600000 55%] Loss:0.332840, Accuracy:86.975\n",
      "Epoch6:[348000/600000 58%] Loss:0.364645, Accuracy:87.078\n",
      "Epoch6:[360000/600000 60%] Loss:0.163521, Accuracy:87.168\n",
      "Epoch7:[376000/600000 63%] Loss:0.251060, Accuracy:87.302\n",
      "Epoch7:[392000/600000 65%] Loss:0.339271, Accuracy:87.408\n",
      "Epoch7:[408000/600000 68%] Loss:0.222536, Accuracy:87.531\n",
      "Epoch7:[420000/600000 70%] Loss:0.178179, Accuracy:87.617\n",
      "Epoch8:[436000/600000 73%] Loss:0.226296, Accuracy:87.731\n",
      "Epoch8:[452000/600000 75%] Loss:0.154056, Accuracy:87.823\n",
      "Epoch8:[468000/600000 78%] Loss:0.170102, Accuracy:87.922\n",
      "Epoch8:[480000/600000 80%] Loss:0.162480, Accuracy:87.995\n",
      "Epoch9:[496000/600000 83%] Loss:0.253008, Accuracy:88.095\n",
      "Epoch9:[512000/600000 85%] Loss:0.299886, Accuracy:88.188\n",
      "Epoch9:[528000/600000 88%] Loss:0.299492, Accuracy:88.273\n",
      "Epoch9:[540000/600000 90%] Loss:0.306129, Accuracy:88.327\n",
      "Epoch10:[556000/600000 93%] Loss:0.270958, Accuracy:88.423\n",
      "Epoch10:[572000/600000 95%] Loss:0.159870, Accuracy:88.514\n",
      "Epoch10:[588000/600000 98%] Loss:0.237747, Accuracy:88.594\n",
      "Epoch10:[600000/600000 100%] Loss:0.234920, Accuracy:88.648\n"
     ]
    }
   ],
   "source": [
    "torch.manual_seed(420)\n",
    "net = Model(in_features=input_, out_features=output_)\n",
    "fit(net, batchdata, lr = lr, epochs=epochs, gamma=gamma)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
